﻿using System;
using System.ServiceModel;
using Ayatta.Contract.Component;
using Ayatta.Contract.Domain;
using System.Collections.Generic;

namespace Ayatta.Contract
{
    [ServiceContract(Namespace = ServiceContract.Namespace)]
    public interface IAuctionService : IService
    {
        #region Auction

        [OperationContract]
        bool CreateAuction(Auction o);

        [OperationContract]
        bool UpdateAuction(Auction o);

        [OperationContract]
        bool DeleteAuction(long id);

        /// <summary>
        /// 生成拍品订单
        /// </summary>
        /// <param name="auctionId">拍品Id</param>
        /// <returns>拍品订单Id</returns>
        [OperationContract]
        string Buy(long auctionId);

        /// <summary>
        /// 计算某用户在某拍品上所花费金额
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="auctionId">拍品Id</param>
        /// <param name="begin">开始时间</param>
        /// <returns>所花费总金额</returns>
        [OperationContract]
        int SumBid(long userId, long auctionId, DateTime? begin = null);

        [OperationContract]
        Auction GetAuction(long id);

        [OperationContract]
        IList<Auction> GetAllAuction();

        [OperationContract]
        PagedList<Auction> GetPagedAuctions(int index = 1, int size = 20, string name = null, AuctionGrade? grade = null,
                                           AuctionStatus? status = null);

        #endregion

        #region Bidding

        [OperationContract]
        PagedList<Bid> GetPagedBidding(int index = 1, int size = 20, long? auctionId = null);

        #endregion

        #region AuctionOrder

        [OperationContract]
        bool CreateAuctionOrder(AuctionOrder o);

        [OperationContract]
        bool UpdateAuctionOrder(AuctionOrder o);

        [OperationContract]
        bool DeleteAuctionOrder(string id);

        [OperationContract]
        AuctionOrder GetAuctionOrder(string id, int? userId = null);

        [OperationContract]
        IList<AuctionOrder> GetAllAuctionOrder();

        [OperationContract]
        PagedList<AuctionOrder> GetPagedAuctionOrder(int index = 1, int size = 20, int? userId = 0,
                                                    AuctionGrade? grade = null, AuctionStatus? status = null);

        #endregion

        #region AuctionShare

        [OperationContract]
        bool CreateAuctionShare(AuctionShare o);

        [OperationContract]
        AuctionShare GetAuctionShare(int id, int? userId = null, AuctionShareStatus? status = null);

        [OperationContract]
        IList<AuctionShare> GetAuctionShares(int userId);

        [OperationContract]
        PagedList<AuctionShare> GetPagedAuctionShares(int index = 1, int size = 20, int? userId = 0,
                                                     string username = null, int? auctionId = null,
                                                     AuctionShareStatus? status = null);

        #endregion

        #region AuctionRobot

        [OperationContract]
        bool CreateAuctionRobot(AuctionRobot o);

        [OperationContract]
        AuctionRobot GetAuctionRobot(int id, int? userId = null, AuctionRobotStatus? status = null);

        [OperationContract]
        IList<AuctionRobot> GetAuctionRobots(int userId);

        [OperationContract]
        PagedList<AuctionRobot> GetPagedAuctionRobots(int index = 1, int size = 20, int? userId = 0,
                                                     string username = null, int? auctionId = null,
                                                     AuctionRobotCategory? category = null,
                                                     AuctionRobotTiming? timing = null,
                                                     AuctionRobotStatus? status = null);

        #endregion
    }
}